export default {
    namespaced: true,
    state: {
        // 是否显示提示框
        isShowToast: false,
        // 提示内容
        toastMsg: '',
        // 提示类型
        toastType:'',   // 'success  danger  warning'
    },
    mutations: {
        changeIsShowToast(state, payload) {
            // payload -- {isShow:true,msg:'请输入正确的手机号',type:'danger'}
            state.isShowToast = payload.isShow
            if (payload.isShow) {
                state.toastMsg = payload.msg
                state.toastType = payload.type
            }
        }
    },
    actions: {
        asyncchangeIsShowToast(context, payload) {
            // console.log('asyncchangeIsShowToast');
            // 调用mutations里面方法----context.commit('方法')
            context.commit('changeIsShowToast', payload)
            setTimeout(() => {
                context.commit('changeIsShowToast',{
                    isShow: false,
                    msg:payload.msg,
                    type:payload.type
                })
              }, 1000);
        }
    }
}